﻿Imports Misa_Visual_Basic_OS_2.dims
Public Class CreateAccount_Step01
    Dim dims As New dims
    Private Sub closeBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeBTN.Click
        Launcher.Close()
    End Sub

    Private Sub continueBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles continueBTN.Click
        Dim usernamePath As String = dims.ProfileDir + dims.privConf + "\" + username.Text + "\" + "username.MVBOS"
        Try
            If (Not System.IO.File.Exists(usernamePath)) Then
                System.IO.File.Create(dims.IsInstFulDir)
                FileSystem.MkDir(dims.ProfileDir + dims.privConf + "\" + username.Text)
                System.IO.File.Create(dims.ProfileDir + dims.privConf + "\" + username.Text + "\" + "username.MVBOS")
                System.IO.File.Create(dims.ProfileDir + dims.privConf + "\" + username.Text + "\" + "password.MVBOS")
                Dim passPath As String = dims.ProfileDir + dims.privConf + "\" + username.Text + "\" + "pass.MVBOS"
                Dim usernameSave As New System.IO.StreamWriter(usernamePath, False)
                usernameSave.WriteLine(username.Text)
                usernameSave.Close()
                Dim passSave As New System.IO.StreamWriter(passPath, False)
                passSave.WriteLine(TextBox1.Text)
                passSave.Close()
            Else
                MessageBox.Show("An user with that name already exists.")
                Launcher.Close()
            End If
        Catch ex As Exception
            Me.Hide()
            MessageBox.Show("We were unable to create required files, application will exit. Maybe you need to run an Admin account! (But you shouldn't)")
            Launcher.Close()
        End Try
        finishStep02.Show()
        Close()
    End Sub
End Class